package ucm;

import java.sql.Connection;
import java.sql.Statement;
import model.Database_Model;

public class UCRegisterPort {

    private String name, address, phone, fax, tax;

    public UCRegisterPort(view.Air_Port ap) {
        this.name = ap.getPortModel().getName();
        this.address = ap.getPortModel().getAddress();
        this.fax = ap.getPortModel().getFax();
        this.phone = ap.getPortModel().getPhone();
        this.tax = ap.getPortModel().getTax();
    }

    public String run() {
        try {
            Connection con = new Database_Model().getConnection();
            Statement stmt = con.createStatement();
            stmt.executeUpdate("update port set name ='" + this.name + "';");
            stmt.executeUpdate("update port set address ='" + this.address + "';");
            stmt.executeUpdate("update port set phone ='" + this.phone + "';");
            stmt.executeUpdate("update port set fax ='" + this.fax + "';");
            stmt.executeUpdate("update port set tax ='" + this.tax + "';");
            return "Congratulate! ";
        } catch (Exception e) {
            return "Failed! ";
        }
    }
}
